﻿$().ready(function () {
    $("#DepartStartDate,#DepartEndDate").datepicker({
        dateFormat: 'yy年mm月dd日',
        numberOfMonths: 3,
        beforeShow: DepartDateRange
    });

    $("#LeaveStartDate,#LeaveEndDate").datepicker({
        dateFormat: 'yy年mm月dd日',
        numberOfMonths: 3,
        beforeShow: LeaveDateRange
    });

    $("#HotelCheckinDate,#HotelCheckoutDate").datepicker({
        dateFormat: 'yy年mm月dd日',
        numberOfMonths: 3,
        beforeShow: HotelCheckDateRange
    });

    function DepartDateRange(input) {
        return { minDate: (input.id == "DepartEndDate" ? $("#DepartStartDate").datepicker("getDate") : null),
            maxDate: (input.id == "DepartStartDate" ? $("#DepartEndDate").datepicker("getDate") : null)
        };
    }

    function LeaveDateRange(input) {
        return { minDate: (input.id == "LeaveEndDate" ? $("#LeaveStartDate").datepicker("getDate") : null),
            maxDate: (input.id == "LeaveStartDate" ? $("#LeaveEndDate").datepicker("getDate") : null)
        };
    }

    function HotelCheckDateRange(input) {
        return { minDate: (input.id == "HotelCheckoutDate" ? $("#HotelCheckinDate").datepicker("getDate") : null),
            maxDate: (input.id == "HotelCheckinDate" ? $("#HotelCheckoutDate").datepicker("getDate") : null)
        };
    }

    $(".reviewedrole input").change(function () {
        if ($(this).attr("id") == "ReviewedRole_1")
            $("#admin-confirm").slideDown();
        else {
            $("#admin-confirm").slideUp();
        }
    });

    $("form").submit(function () {
        if ($(this).valid()) {
            $(".btn-container input").css("disable", "disable");
            $(".btn-container input").val("保存中……");
        }
    });
});